package com.syh.app.basic.utils;

import android.view.Gravity;
import android.view.LayoutInflater;
import android.widget.TextView;
import android.widget.Toast;

import com.syh.app.basic.R;
import com.syh.app.basic.App;

/**
 * 创建者：SYH
 * 时间：2019/9/29 9:24
 * 编辑者：SYH、
 * 补充说明：自定义的 Toast
 */
public class Tooast {

    private Tooast() {
    }

    public static void success(String msg) {
        if (msg != null) {
            Toast toast = new Toast(App.getApplication());
            TextView view = (TextView) LayoutInflater.from(App.getApplication()).inflate(R.layout.tooast_view, null);
            view.setText(msg);
            view.setBackgroundResource(R.drawable.tooast_view_success_bg);
            toast.setView(view);
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
        }
    }

    public static void normalInfo(String msg) {
        if (msg != null) {
            Toast toast = new Toast(App.getApplication());
            TextView view = (TextView) LayoutInflater.from(App.getApplication()).inflate(R.layout.tooast_view, null);
            view.setText(msg);
            view.setBackgroundResource(R.drawable.tooast_view_normal_bg);
            toast.setView(view);
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
        }
    }

    public static void warning(String msg) {
        if (msg != null) {
            Toast toast = new Toast(App.getApplication());
            TextView view = (TextView) LayoutInflater.from(App.getApplication()).inflate(R.layout.tooast_view, null);
            view.setText(msg);
            view.setBackgroundResource(R.drawable.tooast_view_warning_bg);
            toast.setView(view);
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
        }
    }

}
